<?php
/**
 * Created by PhpStorm.
 * User: sid.lee
 * Date: 2019/12/05
 * Email: lx.xin@qq.com
 */
// 后台登录
Route::get('/login', 'AdminController@showLoginForm')->name('backend.login');
Route::post('/login', 'AdminController@loginHandle');
Route::get('/logout', 'AdminController@logoutHandle')->name('backend.logout');

// 修改密码
Route::get('/password/update', 'AdminController@showEditPasswordForm')->name('backend.edit.password');
Route::put('/password/update', 'AdminController@editPasswordHandle');

Route::group(['middleware' => [
    'ip.white.list',
    'backend.login.check',
    'operation.log',
    'check.backend.permission',
]], function () {
    // 主面板
    Route::get('/dashboard', 'DashboardController@index')->name('backend.dashboard.index');

    //管理员
    Route::get('/admin', 'AdminController@index')->name('backend.admin.index');
    Route::get('/admin/create', 'AdminController@create')->name('backend.admin.create');
    Route::post('/admin/create', 'AdminController@store');
    Route::get('/admin/{id}/edit', 'AdminController@edit')->name('backend.admin.edit');
    Route::put('/admin/{id}/edit', 'AdminController@update');
    Route::get('/admin/{id}/destroy', 'AdminController@destroy')->name('backend.admin.destroy');

    //文章
    Route::get('/article', 'ArticleController@index')->name('backend.article.index');
    Route::get('/article/create', 'ArticleController@create')->name('backend.article.create');
    Route::post('/article/create', 'ArticleController@store');
    Route::get('/article/{id}/edit', 'ArticleController@edit')->name('backend.article.edit');
    Route::put('/article/{id}/edit', 'ArticleController@update');
    Route::get('/article/{id}/destroy', 'ArticleController@destroy')->name('backend.article.destroy');

    Route::get('/article/{id}/content', 'ArticleController@content')->name('backend.article.content');
    Route::post('/article/{id}/set-content', 'ArticleController@setContent')->name('backend.article.set-content');
    Route::get('/article/{id}/publish', 'ArticleController@publish')->name('backend.article.publish');

    // 文章评论
    Route::get('/comment', 'CommentController@index')->name('backend.comment.index');
    Route::get('/comment/{id}/destroy', 'CommentController@destroy')->name('backend.comment.destroy');

    //分类
    Route::get('/category', 'CategoryController@index')->name('backend.category.index');
    Route::get('/category/create', 'CategoryController@create')->name('backend.category.create');
    Route::post('/category/create', 'CategoryController@store');
    Route::get('/category/{id}/edit', 'CategoryController@edit')->name('backend.category.edit');
    Route::put('/category/{id}/edit', 'CategoryController@update');
    Route::get('/category/{id}/destroy', 'CategoryController@destroy')->name('backend.category.destroy');

    //tags
    Route::get('/tag', 'TagController@index')->name('backend.tag.index');
    Route::get('/tag/create', 'TagController@create')->name('backend.tag.create');
    Route::post('/tag/create', 'TagController@store')->name('backend.tag.store');
    Route::get('/tag/{id}/edit', 'TagController@edit')->name('backend.tag.edit');
    Route::put('/tag/{id}/edit', 'TagController@update');
    Route::get('/tag/{id}/destroy', 'TagController@destroy')->name('backend.tag.destroy');


    // 角色
    Route::get('/role', 'RoleController@index')->name('backend.role.index');
    Route::get('/role/create', 'RoleController@create')->name('backend.role.create');
    Route::post('/role/create', 'RoleController@store');
    Route::get('/role/{id}/edit', 'RoleController@edit')->name('backend.role.edit');
    Route::put('/role/{id}/edit', 'RoleController@update');
    Route::get('/role/{id}/destroy', 'RoleController@destroy')->name('backend.role.destroy');
    Route::get('/role/{id}/permission', 'RoleController@showSelectPermissionPage')->name('backend.role.permission');
    Route::post('/role/{id}/permission', 'RoleController@handlePermissionSave');


    // 权限
    Route::get('/permission', 'PermissionController@index')->name('backend.permission.index');
    Route::get('/permission/create', 'PermissionController@create')->name('backend.permission.create');
    Route::post('/permission/create', 'PermissionController@store');
    Route::get('/permission/{id}/edit', 'PermissionController@edit')->name('backend.permission.edit');
    Route::put('/permission/{id}/edit', 'PermissionController@update');
    Route::get('/permission/{id}/destroy', 'PermissionController@destroy')->name('backend.permission.destroy');

    // 后台菜单
    Route::get('/menu', 'MenuController@index')->name('backend.menu.index');
    Route::get('/menu/create', 'MenuController@create')->name('backend.menu.create');
    Route::post('/menu/create', 'MenuController@store');
    Route::get('/menu/{id}/edit', 'MenuController@edit')->name('backend.menu.edit');
    Route::put('/menu/{id}/edit', 'MenuController@update');
    Route::get('/menu/{id}/delete', 'MenuController@destroy')->name('backend.menu.destroy');

    // 首页导航 & 友情连接
    Route::get('/link', 'LinkController@index')->name('backend.link.index');
    Route::get('/link/create', 'LinkController@create')->name('backend.link.create');
    Route::post('/link/create', 'LinkController@store');
    Route::get('/link/{id}/edit', 'LinkController@edit')->name('backend.link.edit');
    Route::put('/link/{id}/edit', 'LinkController@update');
    Route::get('/link/{id}/delete', 'LinkController@destroy')->name('backend.link.destroy');

    //配置

    Route::get('/setting', 'SettingController@index')->name('backend.setting.index');
    Route::post('/setting', 'SettingController@saveHandler');

    //操作日志
    Route::get('/operation_log', 'OperationLogController@index')->name('backend.operation_log.index');

    //登陆日志
    Route::get('/login_log', 'LoginLogController@index')->name('backend.login_log.index');

    //会员列表
    Route::get('/member', 'MemberController@index')->name('backend.member.index');
    Route::get('/member/create', 'MemberController@create')->name('backend.member.create');
    Route::post('/member/create', 'MemberController@store');
    Route::get('/member/{id}/delete', 'MemberController@destroy')->name('backend.member.destroy');

});
